import java.util.LinkedList;

/**
 * 
 * This class creates the mule along with all the responsibilities that the mule
 * has. This includes very important roles such as harvest, setting the mule's
 * type and setting the location where it can be placed.
 * 
 * @author GT Five-O
 * @version v1.0b
 * 
 */
public class Mule implements java.io.Serializable {
    private String muleType = null;
    private Property property = null;
    private int price = GameConstants.MULE_PRICE;
    private int muleID;

    private static int ID_COUNTER = 0;

    /**
     * constructor for mule class. Assigns a value to the muleID and increments
     * the ID_COUNTER variable
     */
    public Mule() {
        muleID = ID_COUNTER;
        ID_COUNTER++;
    }

    /**
     * getter for the mule's ID
     * 
     * @return
     */
    public int getMuleID() {
        return muleID;
    }

    /**
     * setter for the mule's land
     * 
     * @param input
     *            the land the mule is placed on
     */
    public void setProperty(Property input) {
        property = input;
    }

    /**
     * getter for the land that the mule resides on
     * 
     * @return
     */
    public Property getProperty() {
        return property;
    }

    /**
     * harvest's the current property and returns the harvest (type dependent on
     * mule type)
     * 
     * @param num
     *            the amount of resource being harvested
     * @return linked list containing all the units of resources (food, ore, or
     *         energy)
     */
    public LinkedList<Resource> harvest(int num) {
        LinkedList<Resource> resc = new LinkedList<Resource>();
        if (muleType.equals("Food")) {
            for (int i = 0; i < num; i++) {
                resc.add(new Food());
            }
        } else if (muleType.equals("Ore")) {
            for (int i = 0; i < num; i++) {
                resc.add(new Ore());
            }
        } else {
            for (int i = 0; i < num; i++) {
                resc.add(new Energy());
            }
        }
        return resc;
    }

    /**
     * setter for the type of mule which determines the cost of the mule
     * 
     * @param s
     *            either Food, Ore or Energy
     */
    public void setType(String s) {
        muleType = s;
        if (s.equals("Food"))
            price = GameConstants.FOOD_MULE_PRICE;
        else if (s.equals("Ore"))
            price = GameConstants.ORE_MULE_PRICE;
        else
            price = GameConstants.ENERGY_MULE_PRICE;
    }

    /**
     * getter for the type of mule
     * 
     * @return
     */
    public String getType() {
        return muleType;
    }

    /**
     * getter for the price of the mule
     * 
     * @return
     */
    public int getPrice() {
        return price;
    }

}
